package com.lcq.demo.common.config;

import com.lcq.demo.common.utils.RedisUtil;
import com.lcq.demo.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author 240701005
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer{

    @Resource
    private RedisUtil redisUtil;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor(redisUtil))
                .addPathPatterns("/**")
                .excludePathPatterns("/s3/** ")
                .excludePathPatterns("/api/users/login")
                .excludePathPatterns("/api/users/register")
                .excludePathPatterns("/api/users/sendVerifyCode")
                .excludePathPatterns("/test/**")
                .excludePathPatterns("/swagger-ui/**")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/swagger-resources/**")
                .excludePathPatterns("/v3/**");
    }

}
